﻿using System;
using System.Windows;
using System.Windows.Interactivity;
using System.Windows.Media.Animation;
using PairingMatrix.ViewModel;

namespace PairingMatrix.View.Behavior
{
    public class MouseOnMingleCardBehavior : Behavior<MingleCardControl>
    {
        protected override void OnAttached()
        {
            AssociatedObject.MouseLeftButtonDown += (sender, e) =>
                                                    {
                                                        AssociatedObject.CaptureMouse();
                                                        AssociatedObject.scale.ScaleX = 0.9;
                                                        AssociatedObject.scale.ScaleY = 0.9;
                                                    };

            AssociatedObject.MouseLeftButtonUp += (sender, e) =>
                                                    {
                                                        AssociatedObject.ReleaseMouseCapture();
                                                        AssociatedObject.scale.ScaleX = 1;
                                                        AssociatedObject.scale.ScaleY = 1;
                                                        AssociatedObject.Visibility = Visibility.Collapsed;
                                                        ((CardWallViewModel)ControlRegistry.CardWallControl.DataContext)
                                                            .AddProjectCardCommand.Execute(AssociatedObject.cardNumber.Text);
                                                    };

        }
    }
}
